@import '../mixins/media';

.controls {
  position: relative;
  display: flex;
  align-items: center;

  &:focus {
    outline: none;
  }
}

.custom-checkbox {
  -webkit-appearance: none;
  width: 1em;
  height: 1em;
  vertical-align: top;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  border: 1px solid;
  border-radius: $space-x1;
  cursor: pointer;
  flex-shrink: 0;

  &:checked {
    cursor: pointer;
    background-image: url($urlPrefix + '/buffet/img/checkbox-marked.svg');
    background-repeat: no-repeat;
  }

  &:focus {
    outline: none;
  }

  &.custom-radio {
    border-radius: 50%;

    &:checked {
      background-image: url($urlPrefix + '/buffet/img/radiobutton-marked.svg');
      background-repeat: no-repeat;
    }
  }
}

@each $color, $value in $theme-colors {
  .custom-checkbox-#{$color} {
    border-color: $value;
  }

  .custom-checkbox-#{$color}:checked {
    border-color: $value;
    background-color: $value;
  }

  .custom-checkbox-#{$color} {
    &.custom-control-input:checked:hover {
      background-color: darken($value, 8%);
      border: 1px solid darken($value, 8%);
    }
  }

  .custom-checkbox-#{$color} {
    &.custom-control-input:hover {
      border: 1px solid darken($value, 8%);
    }
  }

  .custom-checkbox-#{$color} {
    &.custom-control-input:disabled {
      background-color: $white;
      border: 1px solid rgba($value, 0.3);
    }
  }

  .custom-checkbox-#{$color} {
    &.custom-control-input:checked:disabled {
      background-color: rgba($value, 0.3);
      border: 1px solid rgba($value, 0);
    }
  }

  .custom-checkbox-#{$color} {
    &.custom-control-input:disabled {
      cursor: default;
    }
  }
}

.custom-control {
  outline: none;
  z-index: 0;
  display: flex;
  align-items: center;
}

.custom-control-label {
  font-size: 14px;
  line-height: 16px;
  color: $gray-900;
  outline: none;
  cursor: pointer;

  &::before,
  &::after {
    top: 0;
  }

  &.label-disabled {
    cursor: default;
    color: rgba($gray-900, 0.4);
  }
}

.custom-control.hide-label {
  padding-left: 1rem;

  .custom-control-label::before {
    left: -1rem;
  }

  .custom-control-label::after {
    left: -1rem;
  }
}

.form-block-name {
  font-weight: 500;
  font-size: 18px;
  line-height: 20px;
  color: $gray-700;

  &.red {
    color: $red;
  }
}
